'use strict'

class login {
    constructor() {
        this.param = '/'
    }
    //创建资源
    async post(c) {
        //根据贴纸id获取具体贴纸信息
        var loginObj=JSON.parse(c.rawBody);
        try {
            let sqltext1 = `select * from admin WHERE admin_passwd = `
            +`'${loginObj.passwd}' and admin_name='${loginObj.username}'`
            var r1 = await c.service.psql.query(sqltext1);
            if (r1.rowCount == 0) {
                return c.send('登陆失败');
            }
            else{
                return c.send(r1.rows[0]);
            }
        }
        catch (err) {
            console.log(err);
            return c.status(400).send('error');
        }
    }
}

module.exports = login